package com.example.administrator.funchat.activity;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.example.administrator.funchat.fragment.LoginFragment;
import com.example.administrator.funchat.R;
import com.example.administrator.funchat.fragment.RegisterFragment;

/**
 * 注册登录界面
 */
public class RegisterLoginActivity extends AppCompatActivity implements View.OnClickListener {


    public TextView zhuce;
    public TextView denglu;
    public boolean flag = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.register_login_layout);
        zhuce = (TextView) findViewById(R.id.zhuce);
        denglu = (TextView) findViewById(R.id.denglu);
        zhuce.setOnClickListener(this);

    }


    /**
     * 点击事件,点击 注册 登录 按钮切换注册登录fragment碎片
     *
     * @param view
     */
    @Override
    public void onClick(View view) {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
        if (flag) {
            zhuce.setText("登录");
            zhuce.setTextColor(0xFF14337B);
            denglu.setBackgroundResource(R.drawable.zcwenben);
            RegisterFragment registerFragment = new RegisterFragment();
            beginTransaction.replace(R.id.framelayout, registerFragment);
            flag = false;
        } else {
            zhuce.setText("注册");
            zhuce.setTextColor(0xFFD77712);
            denglu.setBackgroundResource(R.drawable.dlwenben);
            LoginFragment loginFragment = new LoginFragment();
            beginTransaction.replace(R.id.framelayout, loginFragment);
            flag = true;
        }
        beginTransaction.commit();

    }

}
